import random
import string

def getjhm():
    Z = string.ascii_uppercase  # 得到大写的A-Z
    S = string.digits  # 得到0-9的数字
    fw = Z + S  # 得到激活码的取值范围
    a = "";
    for i in range(N):
        a += random.choice(fw)
    return a

N=32;  #激活码的位数
a=eval(input("请输入想要生成的激活码个数："))
fp=open("激活码.txt","w+",encoding="utf-8");
fp.write("激活码顺序"+'\t'+"激活码内容"+'\n');
for i in range(1,a+1):
    str=getjhm();
    print(str)
    fp.write("第{}个激活码".format(i)+'\t'+str+'\n');
fp.close()

